package com.clkj.sunhelp.adapter.list;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.clkj.sunhelp.R;
import com.clkj.sunhelp.bean.PublicityItem;

import java.util.List;

/**
 * Created by Administrator on 2017/4/1.
 */

public class ListAdapterForFirstAndSecPublicity extends BaseAdapter {

    List<PublicityItem> mPublicityList;
    Context mContext;
    LayoutInflater mLayoutInflater;

    String mJobKindName;

    public ListAdapterForFirstAndSecPublicity(List<PublicityItem> mPublicityList, Context context) {

        this.mPublicityList = mPublicityList;
        mContext = context;
        mLayoutInflater = LayoutInflater.from(mContext);
    }

    @Override
    public int getCount() {
        return mPublicityList.size();
    }

    @Override
    public Object getItem(int position) {
        return mPublicityList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = mLayoutInflater.inflate(R.layout.list_item_publicity_first_and_sec, null);
            viewHolder = new ViewHolder();
            viewHolder.tvHuzhuName = (TextView) convertView.findViewById(R.id.tv_huzhu_name);
            viewHolder.tvHealthyInfo = (TextView) convertView.findViewById(R.id.tv_healthy_info);
            viewHolder.tvBaozhangPersonNum = (TextView) convertView.findViewById(R.id.tv_baozhang_person_num);
            viewHolder.tvFamliyMonthIncome = (TextView) convertView.findViewById(R.id.tv_famliy_month_income);
            viewHolder.tvFamliyMonthBuzhuMoney = (TextView) convertView.findViewById(R.id.tv_famliy_month_buzhu_money);
            viewHolder.tvMinzhuPingyiResult = (TextView) convertView.findViewById(R.id.tv_minzhu_pingyi_result);
            viewHolder.tvExamResult = (TextView) convertView.findViewById(R.id.tv_exam_result);

            convertView.setTag(viewHolder);

        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        PublicityItem publicityItem = mPublicityList.get(position);


        viewHolder.tvHuzhuName.setText(publicityItem.getHuZhuName());
        viewHolder.tvHealthyInfo.setText(publicityItem.getHealthyInfo());
        viewHolder.tvBaozhangPersonNum.setText(publicityItem.getFamilyPersonNum());
        viewHolder.tvFamliyMonthIncome.setText(publicityItem.getMonthIncomeTotal());
        viewHolder.tvFamliyMonthBuzhuMoney.setText(publicityItem.getMonthBuZhuMoneyTotal());
        viewHolder.tvMinzhuPingyiResult.setText(publicityItem.getMingZhuExamResult());
        viewHolder.tvExamResult.setText(publicityItem.getExamResult());


        return convertView;
    }


    static class ViewHolder {

        private TextView tvHuzhuName;

        private TextView tvHealthyInfo;

        private TextView tvBaozhangPersonNum;

        private TextView tvFamliyMonthIncome;

        private TextView tvFamliyMonthBuzhuMoney;

        private TextView tvMinzhuPingyiResult;

        private TextView tvExamResult;


    }


}
